home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d21
/
dvmulti.arc
/
SUPER.C
< prev
Wrap
C/C++ Source or Header
|
1989-10-25
|
21KB
|
837 lines
/* Supervisor program for DESQview tests
1989 MIPS Magazine / Mark Mallett
*/
#include <stdio.h>
#include <dvapi.h>
#include "dvmulti.h"
/* Macro to ring the alarm */
#define beep() api_sound( 1000, 5 )
/* Fields in the task definition menu */
#define TDF_TSIZE 1 /* Task size */
#define TDF_SLEEP 2 /* Sleep time */
#define TDF_READ 3 /* I/O read */
#define TDF_WRITE 4 /* I/O write */
#define TDF_SEQ 5 /* Sequential I/O */
#define TDF_RAND 6 /* Random I/O */
#define TDF_FSIZE 7 /* File size */
#define TDF_XSIZE 8 /* Transfer size */
#define TDF_BUFC 9 /* Buffers */
#define TDF_IOC 10 /* IO count */
#define TDF_LOOPC 11 /* CPU Loops */
#define TDF_TASKC 12 /* Tasks */
#define TDF_ABORT 13 /* Abort */
#define TDF_CONFIRM 14 /* Confirmation */
#define TDF_FIELDC (14+1) /* Number of fields including
a dummy #0 */
/* Fields in the "go" menu */
#define GO_TIME 1 /* Time for the test */
#define GO_FILENAME 2 /* File for results */
#define GO_ABORT 3 /* Abort */
#define GO_CONFIRM 4 /* Confirmation */
#define GO_FIELDC (4+1) /* # of fields, including #0 */
typedef /* Keeps track of each SLAVE */
struct {
ULONG sd_apphan; /* Application handle */
ULONG sd_malhan; /* Mailbox handle */
char sd_readyF; /* Ready to go */
char sd_doneF; /* Done; received report. */
CNMSG sd_cnmsg; /* Configuration message */
RSMSG sd_rsmsg; /* Report/status message */
} SLAVEDATA;
/* External routines */
extern long atol();
/* Local Variables */
static char Gofile[50]; /* Filename for report */
static ULONG Gotime; /* Execution time */
static ULONG Kbd_go; /* Keboard object for Go menu */
static ULONG Kbd_main; /* Main keyboard object handle */
static ULONG Kbd_tdef; /* Task def keyboard handle */
static ULONG Mal_main; /* Main mailbox */
static ULONG Tim_main; /* Main timer */
static ULONG Win_go; /* GO menu window */
static ULONG Win_main; /* Main window */
static ULONG Win_tdef; /* Task def window handle */
static int SlaveC; /* Number of defined slaves */
static SLAVEDATA Slavetbl[MAXSLAVES]; /* Control info for slaves */
static char Tdf_fields[TDF_FIELDC][20]; /* Task def field values */
static char Tdf_valid[TDF_FIELDC]; /* Valid field indicators */
static char Gomenu[] = "\
\n\
-Execution-\n\
\n\
Period(seconds):\n\
Filename:\n\
\n\
Press RETURN when done\n\
Press ESC to abort ";
static char Goftab[] = {
ftab( GO_FIELDC-1,\
FTH_KEYSELECT+FTH_MODIFIED+FTH_AUTORESET,\
0, 0, ATTR_REVERSE, 2),
3, 18, 3, 27, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
4, 12, 4, 31, FTE_INPUT, FTE_CLEARDFLT, 0, 0,
1, 0, 0, 0, FTE_SELECT, 27, 1, 0,
1, 0, 0, 0, FTE_SELECT, 13, 1, 0
};
static char Prgmenu[] = "\
\n\
-Super-\n\
\n\
Define Task DT\n\
Go GO\n\
Exit EX ";
static char Prgftab[] = {
ftab( 5, FTH_KEYSELECT+FTH_MODIFIED, 0, 0, ATTR_REVERSE, 1 ),
1, 17, 1, 18, FTE_OUTPUT, 0, 0, 0,
3, 1, 3, 19, FTE_SELECT, 'D', 1, 'T',
4, 1, 4, 19, FTE_SELECT, 'G', 1, 'O',
5, 1, 5, 19, FTE_SELECT, 'E', 1, 'X',
3, 0, 0, 0, FTE_SELECT, 27, 1, 0
};
static char Tdefmenu[] = "\
\n\
-Configure-\n\
\n\
Task Size:\n\
Sleep:\n\
Disk IO: READ WRITE SEQ RAND\n\
File Size (KB): Transfer Size:\n\
Buffers: Count:\n\
\n\
CPU\n\
Loops: RETURN when done\n\
Tasks: ESC to abort";
static char Tdefftab[] = {
ftab( TDF_FIELDC-1,\
FTH_KEYSELECT+FTH_MODIFIED+FTH_AUTORESET,\
0, 0, ATTR_REVERSE, 2),
3, 12, 3, 16, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
4, 12, 4, 16, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
5, 11, 5, 14, FTE_SELECT, 0, 1, 0,
5, 16, 5, 20, FTE_SELECT, 0, 1, 0,
5, 22, 5, 24, FTE_SELECT, 0, 1, 0,
5, 26, 5, 29, FTE_SELECT, 0, 1, 0,
6, 20, 6, 26, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
6, 45, 6, 51, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
7, 20, 7, 26, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
7, 45, 7, 51, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
10, 11, 10, 19, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
11, 11, 11, 19, FTE_INPUT, FTE_RIGHTJUST+FTE_CLEARDFLT, 0, 0,
1, 0, 0, 0, FTE_SELECT, 27, 1, 0,
1, 0, 0, 0, FTE_SELECT, 13, 1, 0
};
main()
{
int version; /* Version of current dv */
version = api_init();
if ( version < DVVER ) {
fprintf( stderr, "DESQview version %d.%02d or later required.\n",
DVVER/256, DVVER%256 );
}
else {
api_level( DVVER );
super();
}
if ( version != 0 )
api_exit();
}
/* The functional main program of the supervisor program. Called after
DESQview environment is established. */
super()
{
char field; /* Field selected */
char done;
int kbdL; /* Length of keyboard input */
char *kbdP; /* Ptr to keyboard buffer */
/* Get handles to main window, keyboard, mailbox, and a timer. */
Win_main = win_me();
Kbd_main = key_me();
Mal_main = mal_me();
Tim_main = tim_new();
/* Set logical and physical window sizes for main window */
win_resize( Win_main, 7, 21 );
win_lsize( Win_main, 7, 21 );
/* Position and set to use logical attributes */
win_origin( Win_main, 0, 0 );
win_move( Win_main, 5, 10 );
win_logattr( Win_main, 1 );
win_attr( Win_main, 1 );
/* Enable field mode, no hardware cursor */
key_subfrom( Kbd_main, KBF_CURSOR );
key_addto( Kbd_main, KBF_FIELD );
/* Throw up the main menu */
win_swrite( Win_main, &Prgmenu[0] );
win_stream( Win_main, &Prgftab[0] );
win_redraw( Win_main );
/* Loop processing menu items */
for( done = FALSE; !done; ) {
key_read( Kbd_main, &kbdP, &kbdL );
field = *kbdP;
fld_reset( Win_main );
win_redraw( Win_main );
/* Process the field */
switch( field ) {
case 2: /* Task definition */
if ( SlaveC == MAXSLAVES )
beep(); /* All tasks defined */
else
task_def();
break;
case 3: /* Go */
if ( SlaveC == 0 )
beep(); /* No slaves configured */
else {
go(); /* Run the thing */
done = TRUE; /* And we're done. */
}
break;
case 4: /* Real exit */
case 5: /* Dummy exit */
done = TRUE;
break;
default:
break;
}
}
}
/* Go -- run the suite of slaves */
go()
{
int i;
int taskN; /* Task number */
int readyC; /* Ready count */
int doneC; /* Done count */
int msgcode; /* Message code */
int msgL; /* Length of received message */
char *msgP; /* ptr to input message */
ULONG sendtsk; /* Sending task */
DVP sdvp; /* Descriptor for slave */
SLAVEDATA *slaveP; /* Ptr to slave block */
/* Get report & execution parameters */
if ( !getgo() )
return;
/* Fire up each task */
for( taskN = 0, slaveP = &Slavetbl[0]; taskN < SlaveC;
++taskN, ++slaveP ) {
/* Clear out the dvp */
memset( &sdvp, 0, sizeof( DVP ) );
/* Fill in the dvp to run a copy of slave */
sprintf( &sdvp.dvp_title[0], "SLAVE #%d", taskN );
memset( &sdvp.dvp_title[strlen(&sdvp.dvp_title[0])], ' ',
30-strlen(&sdvp.dvp_title[0]) );
sdvp.dvp_minmem = atol( &Tdf_fields[TDF_TSIZE][0] );
sdvp.dvp_maxmem = sdvp.dvp_minmem + 20;
strcpy( &sdvp.dvp_execcmd[0], "SLAVE.EXE" );
sdvp.dvp_drive = TESTDRIVE;
strcpy( &sdvp.dvp_dir[0], TESTDIR );
sdvp.dvp_tpages = 1;
sdvp.dvp_firstvec = 0;
sdvp.dvp_lastvec = 0xff;
sdvp.dvp_lrows = 2;
sdvp.dvp_lcols = 15;
sdvp.dvp_irow = ((taskN*4)%20) +1;
sdvp.dvp_icol = ((taskN*4)/20) * 17 +1;
sdvp.dvp_ctlbyte1 = 1; /* Swappable */
sdvp.dvp_ctlbyte2 = 0;
sdvp.dvp_swappable = 1;
sdvp.dvp_eclose = 1;
sdvp.dvp_rsv3 = 1; /* Must be 1 */
sdvp.dvp_prows = sdvp.dvp_lrows;
sdvp.dvp_pcols = sdvp.dvp_lcols;
sdvp.dvp_iniscrmode = 0xff;
/* Start up the app */
slaveP->sd_apphan = app_start( &sdvp, sizeof(DVP) );
if ( slaveP->sd_apphan == 0 ) {
beep();
break;
}
slaveP->sd_readyF = FALSE;
slaveP->sd_doneF = FALSE;
if ( ( slaveP->sd_malhan = mal_of( slaveP->sd_apphan ) ) == 0 ) {
beep();
break;
}
/* Send configuration data to the slave */
mal_addto( slaveP->sd_malhan, &slaveP->sd_cnmsg, sizeof(CNMSG),
MSG_CONFIG );
}
/* Wait for READY responses from all the slaves */
for( ; ; ) {
msgcode = mal_read( Mal_main, &msgP, &msgL );
if ( msgcode == MSG_READY ) {
sendtsk = mal_addr( Mal_main );
for( i = 0, slaveP = &Slavetbl[0], readyC = 0;
i < SlaveC; ++i, ++slaveP ) {
if ( sendtsk == slaveP->sd_apphan )
slaveP->sd_readyF = TRUE;
if ( slaveP->sd_readyF )
++readyC;
}
/* If all tasks ready, proceed to next phase */
if ( readyC == SlaveC )
break;
}
}
/* Make sure we're the foreground */
win_top( Win_main );
/* Tell all subtasks to proceed */
for( i = 0; i < SlaveC; ++i )
mal_addto( Slavetbl[i].sd_malhan, NULL, 0, MSG_GO );
/* Wait for the test period */
tim_addto( Tim_main, Gotime * 100 );
tim_read( Tim_main );
/* Tell all tasks to stop */
for( i = 0; i < SlaveC; ++i )
mal_addto( Slavetbl[i].sd_malhan, NULL, 0, MSG_STOP );
/* Get results from all subtasks */
for( ; ; ) {
msgcode = mal_read( Mal_main, &msgP, &msgL );
if ( msgcode == MSG_REPORT ) {
sendtsk = mal_addr( Mal_main );
for( i = 0, slaveP = &Slavetbl[0], doneC = 0;
i < SlaveC; ++i, ++slaveP ) {
if ( sendtsk == slaveP->sd_apphan ) {
slaveP->sd_doneF = TRUE;
memcpy( &slaveP->sd_rsmsg, msgP, sizeof(RSMSG) );
}
if ( slaveP->sd_doneF )
++doneC;
}
/* If all tasks are done, proceed to next phase */
if ( doneC == SlaveC )
break;
}
}
/* Generate report */
report();
}
/* Report the results of the run */
report()
{
int i;
float alltime;
float readtime;
float writetime;
float cputime;
FILE *rfP; /* Report file ptr */
CNMSG *cP;
RSMSG *rP;
if ( ( rfP = fopen( &Gofile[0], "a" ) ) == NULL )
if ( ( rfP = fopen( &Gofile[0], "w" ) ) == NULL ) {
beep();
return;
}
fprintf( rfP, "\n\n" );
for( i = 0; i < SlaveC; ++i ) {
cP = &(Slavetbl[i].sd_cnmsg);
rP = &(Slavetbl[i].sd_rsmsg);
alltime = ((float)rP->rm_alltime)/(float)rP->rm_tick;
readtime = ((float)rP->rm_readtime)/(float)rP->rm_tick;
writetime = ((float)rP->rm_writetime)/(float)rP->rm_tick;
cputime = ((float)rP->rm_cputime)/(float)rP->rm_tick;
fprintf( rfP, "Task %d\n", i );
fprintf( rfP, " Configuration:\n" );
fprintf( rfP, " fsize=%ld xsize=%d bufC=%d ioC=%d\n",
cP->cm_fsize, cP->cm_xsize, cP->cm_iobufC, cP->cm_ioC );
fprintf( rfP, " read=%s write=%s method=%s\n",
cP->cm_readF?"TRUE":"FALSE",
cP->cm_writeF?"TRUE":"FALSE",
cP->cm_seqF?"SEQUENTIAL":"RANDOM" );
fprintf( rfP, " cpuC=%ld sleep=%ld\n",
cP->cm_cpuC, cP->cm_sleep );
fprintf( rfP, " Results:\n" );
fprintf( rfP, " loops=%ld\n", rP->rm_loopC );
fprintf( rfP, " total time=%f\n", alltime );
if ( ( cP->cm_readF || cP->cm_writeF ) &&
( cP->cm_ioC != 0 ) ) {
if ( cP->cm_readF ) {
fprintf( rfP, " read time=%f\n", readtime );
}
if ( cP->cm_writeF ) {
fprintf( rfP, " write time=%f\n", writetime );
}
}
else
fprintf( rfP, " <no I/O>\n" );
fprintf( rfP, " cpu time=%f\n", cputime );
}
fclose( rfP );
}
/* getgo() -- Get execution parameters */
int
getgo()
{
char field; /* Field selected */
char done;
int i;
int fsize;
int tsize;
int kbdstat;
int kbdL; /* Length of keyboard input */
int row, col; /* Current cursor pos */
char *kbdP; /* Ptr to keyboard buffer */
char *fieldP; /* Ptr to field definition */
char fieldbuf[50]; /* Buffer for field value */
/* Allocate a window */
Win_go = win_new( "Execution", 15, 12, 60 );
win_logattr( Win_go, 1 );
win_attr( Win_go, 1 );
win_erase( Win_go );
/* Make its keyboard object and attach to the window */
Kbd_go = key_new();
key_open( Kbd_go, Win_go );
/* Enable field mode with cursor */
key_addto( Kbd_go, KBF_FIELD+KBF_CURSOR );
/* Throw up the go menu */
win_swrite( Win_go, &Gomenu[0] );
/* Send out the field info */
win_stream( Win_go, &Goftab[0] );
/* Highlight the field entry areas && initialize field data */
for( field = 1, fieldP = &Goftab[FTABBASE+6];
field < GO_FIELDC; ++field, fieldP += 8 ) {
if ( ( fieldP[4] & (FTE_INPUT|FTE_SELECT) ) == FTE_INPUT )
field_highlight( Win_go, &Goftab[0], field, ATTR_REVERSE );
}
/* Set defaults */
Gotime = 10L; /* 10 seconds */
strcpy ( &Gofile[0], "dt.rep" ); /* Filename */
/* Make the window visible */
win_move( Win_go, 3, 10 );
win_unhide( Win_go );
win_top( Win_go );
/* Loop processing menu items */
fld_cursor( Win_go, 1 );
for( done = 0; done == 0; ) {
key_read( Kbd_go, &kbdP, &kbdL );
kbdstat = key_status( Kbd_go );
if ( kbdstat != 1 ) {
beep();
continue;
}
/* get current cursor position */
qry_cursor( Win_go, &row, &col );
/* Process the field(s) */
for( ; kbdL > 0; kbdP += tsize, kbdL -= tsize ) {
field = *kbdP;
fsize = *(int *)(kbdP+1);
fieldP = kbdP + sizeof(int) + 1;
tsize = fsize + sizeof(int) + 1;
memcpy( &fieldbuf[0], fieldP, fsize );
fieldbuf[fsize] = '\0';
switch( field ) {
case GO_TIME: /* Execution time */
Gotime = atol( &fieldbuf[0] );
break;
case GO_FILENAME:
strcpy( &Gofile[0], &fieldbuf[0] );
for( i = 0; ; ++i )
if ( Gofile[i] == ' ' ) {
Gofile[i] = '\0';
break;
}
break;
case GO_ABORT: /* Abort request */
done = -1;
break;
case GO_CONFIRM: /* Confirmed exit */
done = 1;
break;
default:
break;
}
}
/* Restore cursor */
win_cursor( Win_go, row, col );
}
/* Close the objects used in this interaction */
key_free( Kbd_go );
win_free( Win_go );
return( done == 1 );
}
/* Program configuration menu -- configure a new set of progs */
task_def()
{
char field; /* Field selected */
char done;
int i;
int fsize;
int tsize;
int kbdstat;
int kbdL; /* Length of keyboard input */
int row, col; /* Current cursor pos */
char *kbdP; /* Ptr to keyboard buffer */
char *fieldP; /* Ptr to field definition */
char fieldbuf[20]; /* Buffer for field value */
/* Allocate a window */
Win_tdef = win_new( "Task Definition", 15, 12, 60 );
win_logattr( Win_tdef, 1 );
win_attr( Win_tdef, 1 );
win_erase( Win_tdef );
/* Make its keyboard object and attach to the window */
Kbd_tdef = key_new();
key_open( Kbd_tdef, Win_tdef );
/* Enable field mode with cursor */
key_addto( Kbd_tdef, KBF_FIELD+KBF_CURSOR );
/* Throw up the tdef menu */
win_swrite( Win_tdef, &Tdefmenu[0] );
/* Send out the field info */
win_stream( Win_tdef, &Tdefftab[0] );
/* Highlight the field entry areas && initialize field data */
for( field = 1, fieldP = &Tdefftab[FTABBASE+6];
field < TDF_FIELDC;
++field, fieldP += 8 ) {
Tdf_valid[field] = FALSE;
Tdf_fields[field][0] = '\0';
if ( ( fieldP[4] & (FTE_INPUT|FTE_SELECT) ) == FTE_INPUT )
tdef_highlight( field, ATTR_REVERSE );
}
/* Mark certain fields as valid */
Tdf_valid[TDF_READ] = TRUE;
Tdf_valid[TDF_WRITE] = TRUE;
Tdf_valid[TDF_SEQ] = TRUE;
Tdf_valid[TDF_RAND] = TRUE;
Tdf_valid[TDF_CONFIRM] = TRUE;
Tdf_valid[TDF_ABORT] = TRUE;
/* Make the window visible */
win_move( Win_tdef, 3, 10 );
win_unhide( Win_tdef );
win_top( Win_tdef );
/* Select SEQUENTIAL I/O */
radio_button( Win_tdef, TDF_SEQ, TDF_RAND, TDF_SEQ );
Tdf_fields[TDF_SEQ][0] = 'Y';
Tdf_fields[TDF_RAND][0] = 'N';
fld_cursor( Win_tdef, 1 );
/* Loop processing menu items */
for( done = 0; done == 0; ) {
key_read( Kbd_tdef, &kbdP, &kbdL );
kbdstat = key_status( Kbd_tdef );
if ( kbdstat != 1 ) {
beep();
continue;
}
/* get current cursor position */
qry_cursor( Win_tdef, &row, &col );
/* Process the field(s) */
for( ; kbdL > 0; kbdP += tsize, kbdL -= tsize ) {
field = *kbdP;
fsize = *(int *)(kbdP+1);
fieldP = kbdP + sizeof(int) + 1;
tsize = fsize + sizeof(int) + 1;
memcpy( &fieldbuf[0], fieldP, fsize );
fieldbuf[fsize] = '\0';
switch( field ) {
case TDF_TSIZE: /* Task size */
tdnum_valid( field, &fieldbuf[0], 20L, 1000L );
break;
case TDF_SLEEP: /* Sleep interval */
tdnum_valid( field, &fieldbuf[0], 0L, 1000L );
break;
case TDF_READ: /* I/O read */
case TDF_WRITE: /* I/O Write */
fld_type( Win_tdef, field,
(*fieldP=='Y')?FLT_SELECT : FLT_DESELECT );
Tdf_fields[field][0] = *fieldP;
break;
case TDF_SEQ: /* Sequential I/O */
case TDF_RAND: /* Random I/O */
radio_button( Win_tdef, TDF_SEQ, TDF_RAND, field );
Tdf_fields[TDF_SEQ][0] = (field==TDF_SEQ ? 'Y' : 'N' );
Tdf_fields[TDF_RAND][0] = (field==TDF_RAND ? 'Y' : 'N' );
break;
case TDF_FSIZE: /* File size */
tdnum_valid( field, &fieldbuf[0], 10L, 5000L );
break;
case TDF_XSIZE: /* Transfer size */
tdnum_valid( field, &fieldbuf[0], 512L, 8192L );
break;
case TDF_BUFC: /* Buffers */
tdnum_valid( field, &fieldbuf[0], 1L, 10L );
break;
case TDF_IOC: /* I/O loops */
tdnum_valid( field, &fieldbuf[0], 0L, 10000L );
break;
case TDF_LOOPC: /* CPU loops */
tdnum_valid( field, &fieldbuf[0], 0L, 5000000L );
break;
case TDF_TASKC: /* Number of tasks */
tdnum_valid( field, &fieldbuf[0], 1L,
(long)(MAXSLAVES-SlaveC) );
break;
case TDF_ABORT: /* Abort request */
done = -1;
break;
case TDF_CONFIRM: /* Confirmed exit */
done = 1; /* Pretend we can leave */
/* Now go through and look for invalidated fields */
for( i = TDF_FIELDC-1; i > 0; --i )
if ( !Tdf_valid[i] ) {
done = 0;
tdef_highlight( i, ATTR_ERROR );
fld_cursor( Win_tdef, i );
}
break;
default:
break;
}
}
/* Restore cursor */
win_cursor( Win_tdef, row, col );
}
/* Close the objects used in this interaction */
key_free( Kbd_tdef );
win_free( Win_tdef );
/* Add slave configuration information if exited with confirm */
if ( done == 1 )
tdef_add();
}
/* Add slave configurations from most recent task definition menu */
tdef_add()
{
int i; /* Scratch */
CNMSG *cnmsgP; /* Ptr to config message */
/* Define slave configuration information */
for( i = atoi( &Tdf_fields[TDF_TASKC][0] ); i > 0; --i, ++SlaveC ) {
cnmsgP = &Slavetbl[SlaveC].sd_cnmsg;
cnmsgP->cm_taskN = SlaveC;
cnmsgP->cm_ioC = atoi( &Tdf_fields[TDF_IOC][0] );
cnmsgP->cm_fsize = atol( &Tdf_fields[TDF_FSIZE][0] ) * 1024;
cnmsgP->cm_xsize = atoi( &Tdf_fields[TDF_XSIZE][0] );
cnmsgP->cm_iobufC = atoi( &Tdf_fields[TDF_BUFC][0] );
cnmsgP->cm_readF = (Tdf_fields[TDF_READ][0] == 'Y');
cnmsgP->cm_writeF = (Tdf_fields[TDF_WRITE][0] == 'Y');
cnmsgP->cm_seqF = (Tdf_fields[TDF_SEQ][0] == 'Y');
cnmsgP->cm_cpuC = atol( &Tdf_fields[TDF_LOOPC][0] );
cnmsgP->cm_sleep = atol( &Tdf_fields[TDF_SLEEP][0] );
}
}
/* tdnum_valid -- valid numerical field return for task definition */
tdnum_valid( field, bufP, minval, maxval )
int field; /* Field number */
char *bufP; /* Returned value */
long minval; /* Minimum allowable */
long maxval; /* Maximum allowable */
{
int sign;
long val; /* Accumulator. */
/* Strip leading spaces */
while( *bufP == ' ' )
++bufP;
/* Store the field string */
strcpy( &Tdf_fields[field][0], bufP );
sign = 1;
val = 0;
if ( *bufP == '-' ) {
sign = -1;
++bufP;
}
for( ; *bufP != '\0'; ++bufP ) {
if ( ( *bufP < '0' ) || ( *bufP > '9' ) ) {
Tdf_valid[field] = FALSE;
return;
}
val = val*10 + (*bufP - '0');
}
val = val * sign;
if ( ( val < minval ) || ( val > maxval ) )
Tdf_valid[field] = FALSE;
else {
Tdf_valid[field] = TRUE;
tdef_highlight( field, ATTR_REVERSE );
}
}
/* Radio button processing -- light only one button of a group. */
radio_button( win, first, last, chosen )
ULONG win; /* The window */
int first; /* First of set */
int last; /* Last of set */
int chosen; /* The one selected */
{
int i; /* Scratch */
for( i = first; i <= last; ++i )
fld_type( win, i, (i == chosen) ? FLT_SELECT : FLT_DESELECT );
}
/* Highlight a field in the task definition menu */
tdef_highlight( field, attr )
int field; /* Field to highlight */
int attr; /* Attribute to use */
{
field_highlight( Win_tdef, &Tdefftab[0], field, attr );
}
/* Highlight a field within a menu */
field_highlight( win, ftabP, field, attr )
ULONG win; /* Window handle */
char *ftabP; /* Ptr to field table */
int field; /* Which field */
int attr; /* Attribute to use */
{
/* Skip over the field overhead */
ftabP += FTABBASE+6;
/* Skip to the particular field */
ftabP += (field-1)*8;
/* Highlight the field area */
win_cursor( Win_tdef, ftabP[0], ftabP[1] );
win_repattr( Win_tdef, ftabP[3]-ftabP [1]+1, attr );
}